import { createApp } from "vue"
import "./style.css"
import 'normalize.css'
import App from "./App.vue"
import "./samples/node-api"

import ElementPlus from "element-plus"
import "element-plus/dist/index.css"
import { createPinia } from "pinia"
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import router from "./router/router"
// 添加启动日志，确认拦截器正常工作
console.log("应用启动中，环境:", import.meta.env.MODE)

// 创建Pinia存储
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)

// 创建应用实例
const app = createApp(App)

// 添加插件
app.use(ElementPlus)
app.use(pinia)
app.use(router)

// 挂载应用
app.mount("#app").$nextTick(() => {
  postMessage({ payload: "removeLoading" }, "*")
  console.log("应用挂载完成")
})

// 移除全局未捕获异常监听器，因为现在通过ErrorStore处理
// 这些处理器已经移至App.vue中处理
if (window.removeEventListener) {
  const noop = () => {}
  window.removeEventListener('unhandledrejection', noop)
  window.removeEventListener('error', noop)
}
